package com.feihong.yw189.bluetooth.adpater;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.feihong.yw189.R;

import java.util.ArrayList;

/**
 * 2017/8/17.
 */
public class BleAdapter extends BaseAdapter {
    private ArrayList<String> bleNameList;
    private Context mContext;

    public BleAdapter(Context mContext, ArrayList<String> bleNameList) {
        this.bleNameList = bleNameList;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return bleNameList.size() > 0 ? bleNameList.size() : 0;
    }

    @Override
    public String getItem(int position) {
        return bleNameList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View view = View.inflate(mContext, R.layout.item_ble, null);
        TextView tv_ble = (TextView) view.findViewById(R.id.tv_ble);
        tv_ble.setText(getItem(position));
        return view;
    }
}
